#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

// set NOISY_TEST to 0 to remove printfs from output
#define NOISY_TEST 1

int main() {
    int i;
    int seed = 500;
    int numPlayer = 2;
    int r;
	int choices;

    int k[10] = {adventurer, council_room, feast, gardens, mine
               , remodel, smithy, village, baron, great_hall};
    struct gameState G;

	int stewards[MAX_HAND];
	for (i = 0; i < MAX_HAND; i++) {
		stewards[i] = steward;
	}

	printf("TESTING STEWARD THROUGH CARDEFFECT\n");
	for (choices = 1; choices <= 3; choices++) { 
		memset(&G, 23, sizeof(struct gameState));   // clear the game state
		r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
		G.handCount[0] = 5; // set hand count
		G.numActions = 5; // set action count
		memcpy(G.hand[0], stewards, sizeof(int) * G.handCount[0]);  // sets all cards in hand to steward
	
		printf("Player 0: %d cards, %d coins\n", G.handCount[0], G.coins);

		if (choices == 1) {
			#if (NOISY_TEST == 1)
				printf("CHOICE 1: +2 CARDS\n");
			#endif
			cardEffect(steward, 1, -1, -1, &G, -1, 0);
		}
		else if (choices == 2) {
			#if (NOISY_TEST == 1)
				printf("CHOICE 2: +2 GOLD\n");
			#endif
			cardEffect(steward, -1, 2, -1, &G, -1, 0);
		}
		else if (choices == 3) {
			#if (NOISY_TEST == 1)
				printf("CHOICE 3: -2 CARDS\n");
			#endif
			cardEffect(steward, -1, 3, 2, &G, -1, 0);
		}

		#if (NOISY_TEST == 1)
			printf("Player 0: %d cards, %d coins\n\n", G.handCount[0], G.coins);
		#endif
	}

	printf("TESTING STEWARD THROUGH PLAYCARD\n");
	for (choices = 1; choices <= 3; choices++) { 
		memset(&G, 23, sizeof(struct gameState));   // clear the game state
		r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
		G.handCount[0] = 5; // set hand count
		G.numActions = 5; // set action count
		memcpy(G.hand[0], stewards, sizeof(int) * G.handCount[0]);  // sets all cards in hand to steward
	
		printf("Player 0: %d cards, %d coins\n", G.handCount[0], G.coins);

		if (choices == 1) {
			#if (NOISY_TEST == 1)
				printf("CHOICE 1: +2 CARDS\n");
			#endif
			playCard(0, 1, -1, -1, &G);
		}
		else if (choices == 2) {
			#if (NOISY_TEST == 1)
				printf("CHOICE 2: +2 GOLD\n");
			#endif
			playCard(0, -1, 2, -1, &G);
		}
		else if (choices == 3) {
			#if (NOISY_TEST == 1)
				printf("CHOICE 3: -2 CARDS\n");
			#endif
			playCard(0, -1, 3, 2, &G);
		}

		#if (NOISY_TEST == 1)
			printf("Player 0: %d cards, %d coins\n\n", G.handCount[0], G.coins);
		#endif
	}

    printf("All steward tests completed!\n");

    return 0;
}
